package com.ztf0337.mycurriculumdesign.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.ztf0337.mycurriculumdesign.entity.ParkingSpace;

import java.util.List;

@Dao
public interface ParkingSpaceDao {
    @Insert
    long insert(ParkingSpace parkingSpace);
    @Delete
    void delete(ParkingSpace parkingSpace);
    @Update
    void update(ParkingSpace parkingSpace);
    @Query("SELECT * FROM parking_space_table WHERE id = :id")
    ParkingSpace getParkingSpaceById(Long id);
    @Query("SELECT * FROM parking_space_table WHERE park_lot_id = :id")
    List<ParkingSpace> getParkingSpacesByParkLotId(Long id);

    @Query("SELECT * FROM parking_space_table WHERE type = :type")
    List<ParkingSpace> getParkingSpacesByType(String type);

    @Query("SELECT * FROM parking_space_table WHERE parking_space_number LIKE '%' || :content || '%' " +
            "AND park_lot_id = :parkLotId")
    List<ParkingSpace> searchParkingSpaces(String content, Long parkLotId);

    @Query("DELETE FROM parking_space_table WHERE park_lot_id = :id")
    void deleteByLotId(Long id);

}
